package com.ch.dsms_backend.controller;

import com.ch.dsms_backend.entity.AUser;
import com.ch.dsms_backend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
public class AdminController {
    @Autowired
    private UserService userService;

    @CrossOrigin //跨域访问
    @PostMapping(value="/register")
    public String register(@RequestBody AUser requestUser){
        return userService.register(requestUser);
    }

    @CrossOrigin
    @RequestMapping(value="/login")
    public String login(@RequestBody AUser requestUser,HttpSession session){
        return userService.login(requestUser,session);
    }

    @CrossOrigin
    @RequestMapping(value="/greet")
    public String greet(HttpSession session){
        return "'Bonjourno!'";
    }


}
